package com.springboot.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.springboot.dao.PersonDao;
import com.springboot.pojo.Person_1;

@Controller
public class PersonController_1 {
	@Autowired
	private PersonDao personDao;
	@RequestMapping(value="/save",method=RequestMethod.POST)
	@ResponseBody
	public List<Person_1> savePerson(@RequestBody String name){
		Person_1 p=new Person_1(name);
		personDao.save(p);
		List<Person_1> list=personDao.findAll(new PageRequest(0, 10)).getContent();
		return list;
	}
}
